
let form = layui.form

form.verify({
    len:[/^\S{6,12}$/,'长度6-12位且不能有空格'],


    diff: function(val){
        // 判断
        if(val === $('input[name=oldPwd]').val()){
            return '新密码不能和原密码一致'
        }
    },

    same: function(val){
        // 判断
        if(val !== $('input[name=newPwd]').val()){
            return '两次输入的密码必须一致'
        }
    }

})

// 发送ajax请求
$('form').on('submit',function(e){
    e.preventDefault()
    let data = $(this).serialize()
    axios.post('/my/user/updatepwd',data).then(res=>{
        let {status,message} = res.data
        if(status ===0){
            layer.msg(message)
        }
    })
})

